#ifndef POPUPLOGINMSG_HPP_
#define POPUPLOGINMSG_HPP_

#include "PopupAbstractMessage.hpp"

namespace Popup
{
  struct LoginMsg : public AbstractMessage
  {
    enum { LOGIN = 0xEBA1, PASSWORD = 0xC0C0, CREATEUSER = 0xCACA };

    //! Constructor used in order to send login request
    LoginMsg(const std::string & p_login,
                  const std::string & p_password,
                  bool p_createUser = false) :
      AbstractMessage(POPUP_MSG_TYPE_LOGIN, POPUP_ENCRYPTION_BLOWFISH),
      login(p_login), password(p_password), createUser(p_createUser) {}

    //! Constructor used in order to received a login request
    LoginMsg(const Message *p_message);

    ~LoginMsg() {}

    //!@Override
    bool onSend();

    //!@Override
    bool onReceive();

    inline const std::string & getLogin() const { return login; }
    inline const std::string & getPassword() const { return password; }
    inline bool isCreateRequest() const { return createUser; }

  private:
    std::string login;
    std::string password;
    bool createUser;
  };
}

#endif // POPUPLOGINMSG_HPP_
